﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using C.Unite;
using ChanExt;
using System.Configuration;
using System.Web.Configuration;

namespace ArtLand.OA.Project.SystemMgr
{
    public partial class SysCaCheMgr : CommonPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public static void UpdateConnectionString(string newName, string newConString, string newProviderName, string path)
        {
            string[] strs = path.Split('\\');
            string exePath = strs[strs.Length - 2];
            ConnectionStringSettings mySettings = new ConnectionStringSettings(newName, newConString, newProviderName);
            Configuration config = WebConfigurationManager.OpenWebConfiguration("/" + exePath);
            config.ConnectionStrings.ConnectionStrings.Remove(newName);
            config.ConnectionStrings.ConnectionStrings.Add(mySettings);
            config.ConnectionStrings.SectionInformation.ForceSave = true;
            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("connectionStrings");
        }

        protected void ReloadCache(object sender, EventArgs e)
        {
            DBCaChe.ReLoadPerList();
            DBCaChe.RefreshModelsList();
            Alert.ShowInTop("重载缓存成功！");
        }
    }
}